package com.rr.mymoney.utils;

import java.io.Serializable;

import com.rr.mymoney.model.Account;
import com.rr.mymoney.model.Category;
import com.rr.mymoney.model.Currency;

public class Filter implements Serializable {
    private static final long serialVersionUID = 885268596390387187L;

    private Account account = new Account();
    private Currency currency = new Currency();
    private Category category = new Category();
    private Integer year = DateUtils.getCurrentYear();
    private Integer month = DateUtils.getCurrentMonth();
    private boolean groupByAccount = false;
    private boolean groupByCategory = false;
    private boolean groupByYear = false;
    private boolean showAllMonths = false;
    private boolean showAllYears = false;
    private boolean showIgnored = false;

    public Account getAccount() {
	return account;
    }

    public void setAccount(Account account) {
	this.account = account;
    }

    public Currency getCurrency() {
	return currency;
    }

    public void setCurrency(Currency currency) {
	this.currency = currency;
    }

    /**
     * @return the year
     */
    public Integer getYear() {
	return year;
    }

    /**
     * @param year
     *            the year to set
     */
    public void setYear(Integer year) {
	this.year = year;
    }

    /**
     * @return the month
     */
    public Integer getMonth() {
	return month;
    }

    /**
     * @param month
     *            the month to set
     */
    public void setMonth(Integer month) {
	this.month = month;
    }

    public Integer getYearMonth() {
	return year * 100 + month;
    }

    public void setYearMonth(Integer yearMonth) {
	year = DateUtils.getYear(yearMonth);
	month = DateUtils.getMonth(yearMonth);
    }

    /**
     * @return the category
     */
    public Category getCategory() {
	return category;
    }

    /**
     * @param category
     *            the category to set
     */
    public void setCategory(Category category) {
	this.category = category;
    }

    /**
     * @return the groupByAccount
     */
    public boolean isGroupByAccount() {
	return groupByAccount;
    }

    /**
     * @param groupByAccount
     *            the groupByAccount to set
     */
    public void setGroupByAccount(boolean groupByAccount) {
	this.groupByAccount = groupByAccount;
    }

    /**
     * @return the groupByCategory
     */
    public boolean isGroupByCategory() {
	return groupByCategory;
    }

    /**
     * @param groupByCategory
     *            the groupByCategory to set
     */
    public void setGroupByCategory(boolean groupByCategory) {
	this.groupByCategory = groupByCategory;
    }

    /**
     * @return the groupByYear
     */
    public boolean isGroupByYear() {
	return groupByYear;
    }

    /**
     * @param groupByYear
     *            the groupByYear to set
     */
    public void setGroupByYear(boolean groupByYear) {
	this.groupByYear = groupByYear;
    }

    /**
     * @return the showAllMonths
     */
    public boolean isShowAllMonths() {
	return showAllMonths;
    }

    /**
     * @param showAllMonths
     *            the showAllMonths to set
     */
    public void setShowAllMonths(boolean showAllMonths) {
	this.showAllMonths = showAllMonths;
    }

    /**
     * @return the showAllYears
     */
    public boolean isShowAllYears() {
	return showAllYears;
    }

    /**
     * @param showAllYears
     *            the showAllYears to set
     */
    public void setShowAllYears(boolean showAllYears) {
	this.showAllYears = showAllYears;
    }
    

    /**
     * @return the showIgnored
     */
    public boolean isShowIgnored() {
        return showIgnored;
    }

    /**
     * @param showIgnored the showIgnored to set
     */
    public void setShowIgnored(boolean showIgnored) {
        this.showIgnored = showIgnored;
    }

    @Override
    public String toString() {
	StringBuilder builder = new StringBuilder();
	builder.append("Filter [account=").append(account).append(", currency=").append(currency).append(", yearMonth=").append(getYearMonth())
		.append(", category=").append(category).append("]");
	return builder.toString();
    }

}
